<?php get_instance()->view('common/header');?>
<body>
<div class="chuizhi p10_0 pt30" style="background: url('<?php echo $this->staticUrl?>img/jpg/pic19.jpg') no-repeat;background-size: 100%;  background-attachment:fixed;  background-position-y: -2em;">
    <div class="maxuserimg"><img src="<?php echo $user['userPortrait']?>" alt=""></div>
    <div class="m5_0"><b class="f12 dk tc lh10"><?php echo $user['userName']?></b><span class="f09 tc"><?php echo $user['userMobile']?></span></div>
</div>
<div class="saixuan twosai">
    <a href="<?php echo getUrl('find?id='.$relationId)?>" class="actived"><?php echo $title?>（<?php echo $count['find']?>）</a>
    <?php if ($relationId == $this->userId):?>
        <a href="<?php echo getUrl('friendsCircle/myFriendsCircle?id='.$relationId)?>" class="actived"> 我的动态 （<?php echo $count['friends']?>）</a>
    <?php else:?>
        <a href="<?php echo getUrl('friendsCircle?type=1&id='.$relationId)?>" class="actived">  他的动态（<?php echo $count['friends']?>）</a>
    <?php endif;?>
    <div class="after"></div>
</div>
<?php if (!empty($list)):?>
<div class=" weui-panel_access">
    <div class="weui-panel__bd list">
        <?php foreach ($list as $k => $v):?>
            <div
                <?php if ($isMe):?> class="weui-media-box  weui-cell_swiped listnoline bor_bb p0 location_href"
                <?php else:?> class="weui-media-box listnoline bor_bb p0 location_href" <?php endif;?>
                 href="<?php echo getUrl('find/details?find_id='.$v['id'])?>">
                <div class="weui-cell__bd p10">
                    <div class="heng vCenter">
                        <h4 class="weui-media-box__title mb5 textEll widtitle"><?php echo $v['title']?></h4>
                        <span class="f07 cor9">浏览<?php echo $v['read_number']?>次</span>
                    </div>
                    <p class="weui-media-box__desc cor6"><?php echo $v['content']?></p>
                    <div class="hengright mt10">
                        <div class="f07 cor9 mr10 widcons textEll">
                            <img src="<?php echo $this->staticUrl?>img/png/pic36.png" class="heightimg mr5 di mbmin" alt=""><?php echo $v['address']?>
                        </div>
                        <span class="f07 cor9"><?php echo $v['addtime']?></span>
                    </div>
                </div>
                <?php if ($isMe):?>
                    <div class="weui-cell__ft">
                        <a class="weui-swiped-btn weui-swiped-btn_warn delete-swipeout" href="<?php echo getUrl('find/edit?id='.$v['id'])?>">编辑</a>
                        <a class="weui-swiped-btn weui-swiped-btn_default close-swipeout ajax-request-btn"
                           alert-message="是否确认删除？" href="<?php echo getUrl('find/rmMyFind?find_id='.$v['id'])?>">删除</a>
                    </div>
                <?php endif;?>
            </div>
        <?php endforeach;?>
    </div>
    <div class="weui-loadmore" style="display: none">
        <div class="load">
            <i class="weui-loading"></i>
            <span class="weui-loadmore__tips">正在加载</span>
        </div>
        <span class="noC" style="display: none">没有更多内容了~</span>
    </div>
</div>
<?php else:?>
    <div class="statebox chuizhi jdjz" style="flex: 1;height: 63%;">
        <img class="stateimgda mb5" src="<?php echo $this->staticUrl?>img/default/2.png" alt="">
        <span class="f09 cor9 tc mb20">主人，您还没有发布信息哦~</span>
    </div>
<?php endif;?>
<?php if ($isMe):?>
    <div class="posibtn">
        <a href="<?php echo getUrl('find/add')?>"><img src="<?php echo $this->staticUrl?>img/png/pic133.png" alt=""></a>
    </div>
<?php endif;?>
</body>
<script src="<?php echo $this->staticUrl?>js/jquery-weui.js"></script>
<script src="<?php echo $this->staticUrl?>js/base.js"></script>
<script type="text/javascript">
    $(function () {
        $(".list").delegate('.location_href', 'click', function () {
            var h = $(this).attr('href');
            window.location.href = h;
        });

        /**
         * 上拉加载数据
         */
        var page = 1,
            relationId = "<?php echo $relationId?>",
            isMe = "<?php echo $isMe?>";
        var loading = false;  //状态标记
        $(document.body).infinite().on("infinite", function() {
            if(loading) return;
            loading = true;
            $(".weui-loadmore").show();
            $(".load").show();
            $(".noC").hide();
            // $(document.body).destroyInfinite() // 销毁插件
            // $(document.body).infinite() // 重新初始化
            $.ajax('<?php echo getUrl('find/getList');?>', {
                type:'post',
                data:{page:page,relationId:relationId},
                dataType:'json',
                error:function(){
                    show_message({status:0, message:'请求超时'});
                },
                timeout:60000,
                success:function(e){
                    loading = false;
                    if (e.status == 0){
                        show_message(e);
                        return;
                    }

                    if (!e.data.length){
                        $(document.body).destroyInfinite();
                        $(".load").hide();
                        $(".noC").show();
                        return;
                    }
                    page += 1;
                    $(".weui-loadmore").hide();
                    var html,
                        addressImg = "<?php echo $this->staticUrl?>img/png/pic36.png";
                    $.each(e.data, function (key, obj) {
                        var detailsUrl = "<?php echo getUrl('find/details?find_id=')?>"+obj.id,
                            editUrl = "<?php echo getUrl('find/edit?id=')?>"+obj.id,
                            rmMyFindUrl = "<?php echo getUrl('find/rmMyFind?find_id=')?>"+obj.id,
                            deClass = 'weui-media-box weui-cell_swiped listnoline bor_bb p0 location_href';
                        var oHtml =
                            '<div class="weui-cell__ft">' +
                            '   <a class="weui-swiped-btn weui-swiped-btn_warn delete-swipeout" href="'+editUrl+'">' +
                            '       编辑</a>' +
                            '   <a class="weui-swiped-btn weui-swiped-btn_default close-swipeout ajax-request-btn"' +
                            '       alert-message="是否确认删除？" href="'+rmMyFindUrl+'">删除</a>' +
                            '</div>';
                        if (!isMe){
                            deClass = 'weui-media-box listnoline bor_bb p0 location_href';
                            oHtml = '';
                        }
                        html =
                            '<div class="'+deClass+'" href="'+detailsUrl+'">' +
                                '<div class="weui-cell__bd p10">' +
                                    '<div class="heng vCenter">' +
                                        '<h4 class="weui-media-box__title mb5 textEll widtitle">'+obj.title+'</h4>' +
                                        '<span class="f07 cor9">浏览'+obj.read_number+'次</span>' +
                                    '</div>' +
                                    '<p class="weui-media-box__desc cor6">'+obj.content+'</p>' +
                                    '<div class="hengright mt10">' +
                                        '<div class="f07 cor9 mr10 widcons textEll">' +
                                            '<img src="'+addressImg+'" class="heightimg mr5 di mbmin" alt="">' +
                                        obj.address+'</div>' +
                                        '<span class="f07 cor9">'+obj.addtime+'</span>' +
                                    '</div>' +
                                '</div>' +oHtml+
                            '</div>';
                        $(".list").append(html);
                    });
                }
            });
        });
    })
</script>
</html>